package com.mall.server.controller;


import com.mall.model.vo.CommonResult;
import com.mall.server.service.OssService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.CrossOrigin;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.multipart.MultipartFile;

import java.util.HashMap;

@CrossOrigin
@RestController
@RequestMapping("/aliyun")
public class OssController {

    @Autowired
    private OssService ossService;


    @PostMapping("/oss/upload")
    public CommonResult ossLogo(MultipartFile photoFile) {

        String fileName = ossService.ossLogo(photoFile);
        HashMap<String, String> map = new HashMap<String, String>();
        map.put("url", fileName);
        return CommonResult.success(map);
    }


}
